/**
 * 
 */
package de.lehrbaum.outlokker.misc;

import java.util.EnumMap;

import de.lehrbaum.outlokker.start.StartSurface;

/**
 * Defines all possible settings with their default values.
 * 
 * @author Ulic Quel-droma
 * @version 1.0
 */
public enum SETTINGS {
	/** The element that is centered on the startscreen. */
	START_CENTERELEMENT(StartSurface.PART.EMAIL.name());
	private static EnumMap<SETTINGS, String> values;
	private String defaultVal;
	
	SETTINGS(String defaultVal) {
		this.defaultVal = defaultVal;
	}
	
	/**
	 * @return The value of this setting.
	 */
	public String getString() {
		String value = SETTINGS.values.get(this);
		if (value == null)
			return defaultVal;
		else
			return value;
	}
	
	/**
	 * @param value The value to set.
	 */
	public void setString(String value) {
		if (value.equals(defaultVal))
			SETTINGS.values.put(this, null);
		else
			SETTINGS.values.put(this, value);
	}
	
	/**
	 * @param o The value to set.
	 */
	public void setObject(Object o) {
		String value;
		if (o instanceof Enum)
			value = ((Enum<?>) o).name();
		else
			value = o.toString();
		setString(value);
	}
}